#include "NormalHelp.h"
#include "NormalMenu.h"
#include "VisibleRect.h"
#include "Resources.h"

CCScene* NormalHelp::scene()
{
	CCScene *pScene = CCScene::create();
	pScene->addChild(NormalHelp::create());
	return pScene;
}

bool NormalHelp::init()
{
	bool bRet = false;
	do 
	{
		CC_BREAK_IF(!BaseLayer::init());
		addBg(kBG1);
		CCTexture2D *pT = CCTextureCache::sharedTextureCache()->textureForKey(s_screens5);
		CCSprite *pGuide = CCSprite::createWithTexture(pT, CCRectMake(150, 430, 260, 290));
		CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
		float scale = screenSize.height / pGuide->getContentSize().height;
		pGuide->setScale(1.5);
		pGuide->setPosition(ccpAdd(VisibleRect::center(), ccp(0, 60)));
		
		CCRect rect = CCRectMake(230, 730, 90, 90);
		CCSprite *pN1 = CCSprite::createWithTexture(pT, rect);
		CCSprite *pS1 = CCSprite::createWithTexture(pT, rect);
		CCSprite *pD1 = CCSprite::createWithTexture(pT, rect);
		CCMenuItemSprite *pItem = CCMenuItemSprite::create(pN1, pS1, pD1, this, menu_selector(NormalHelp::onBack));
		pItem->setPosition(ccpAdd(VisibleRect::bottom(), ccp(0, 90)));
		pItem->setScale(1.5f);
		CCMenu *pMenu = CCMenu::create(pItem, NULL);
		pMenu->setPosition(CCPointZero);
		this->addChild(pMenu);
		this->addChild(pGuide);
		bRet = true;
	} while (0);
	return bRet;
}
void NormalHelp::keyBackClicked()
{
	backToMenu();
}
void NormalHelp::onBack(CCObject *pSender)
{
	backToMenu();
}
void NormalHelp::backToMenu()
{
	REPLACE_SCENE(CCTransitionFade, 0.5f, NormalMenu)
	/*CCTransitionFade *pScene = CCTransitionFade::create(0.5f, NormalMenu::scene());
	CCDirector::sharedDirector()->replaceScene(pScene);*/
}